using System;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace SharpGL.SceneGraph.Cameras
{
    /// <summary>
    /// This camera contains the data needed to perform a Frustum transformation
    /// to the projection matrix.
    /// </summary>
    [DataContract()]
    public class FrustumCamera : OrthographicCamera
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="FrustumCamera"/> class.
        /// </summary>
        public FrustumCamera()
        {
            Name = "Camera (Frustum)";
        }

        #endregion Constructors

        #region Public Methods

        /// <summary>
        /// This is the main function of the camera, perform a Frustrum (in this case)
        /// transformation.
        /// </summary>
        public override void TransformProjectionMatrix(OpenGL gl)
        {
            if (OpenGL.IsValidContext(gl))
            {
                //  Perform the transformation.
                gl.Translate(Position.X, Position.Y, Position.Z);
                gl.Frustum(Left, Right, Bottom, Top, Near, Far);
            }
        }

        #endregion Public Methods
    }
}
